<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../js/vue.js"></script>
    <style>
        *{padding: 0;margin: 0;}
        li{list-style: none;}
        a{
            text-decoration: none;
            color: inherit;
        }
        html{
            font-size: -webkit-calc(100vw / 7.5);
        }
        body{
            font-size: 0.24rem;
        }
        html,body,#app{
            width: 100%;
            height: 100%;
        }
        #app{
            display: flex;
            flex-direction: column;
            align-content: space-between;
        }

        #app .app-main{
            display: flex;
            flex-direction: column;
            align-content: space-between;
            flex:1;
        }
        #app .app-header,#app .app-footer{
            height: 1rem;
            background-color: grey;
        }
       
        #app .app-content{
            flex:1;
            overflow-y: auto;
        }
        #app .app-footer {
            display: flex;
            text-align: center;
            line-height: 1rem;
        }
        #app .app-footer a{
            flex:1;
        }
    </style>
</head>
<body>
    <div id="app">
        <!-- <div class="app-main">
            <div class="app-header"></div>
            <div class="app-content">
                主页
            </div>
        </div> -->
        <component :is="curCom"></component>
        
        <div class="app-footer">
            <a href="javascript:;" @click="curCom='home'">主页</a>
            <a href="javascript:;" @click="curCom='list'">列表</a>
            <a href="javascript:;" @click="curCom='car'">购物车</a>
            <a href="javascript:;" @click="curCom='mine'">我的</a>
        </div>
    </div>
</body>
<script type="module">
    // 单页面应用  => 把所有的页面都注册为组件实例,然后在根组件及其子组件中使用 

    import Home from "../components/home.js";
    import List from "../components/list.js";
    import Car from "../components/car.js";
    import Mine from "../components/mine.js";


    var vm = new Vue({
        el:"#app",
        data:{
            curCom:"home",
        },
        components:{
            Home:Home,
            List,
            Car,
            Mine,
        }
    })
</script>
<script>
    /* let Home = {
        data(){
            return {

            }
        },
        template:`<div class="app-main">
            <div class="app-header">主页</div>
            <div class="app-content">
                主页xxx
            </div>
        </div>`
    }

    let List = {
        data(){
            return {

            }
        },
        template:`<div class="app-main">
            <div class="app-header">列表</div>
            <div class="app-content">
                列表xxx
            </div>
        </div>`
    }

    let Car = {
        data(){
            return {

            }
        },
        template:`<div class="app-main">
            <div class="app-header">购物车</div>
            <div class="app-content">
                购物车xxx
            </div>
        </div>`
    }

    let Mine = {
        data(){
            return {

            }
        },
        template:`<div class="app-main">
            <div class="app-header">我的</div>
            <div class="app-content">
                我的xxx
            </div>
        </div>`
    } */
    
</script>
</html>